import { InputQuestion, QuestionBase, SelectQuestion, TableBase, TextTable, TimeQuestion } from '@/components/public-template';
import { Api } from '@/config/api/statement';
import { regExp } from '@/utils/regExp';

class HomeService {
  getQuestions() {
    const questions: QuestionBase<any>[] = [
      new InputQuestion({
        key: 'filesBoxCode',
        label: '档案编码',
        value: null
      }),
      new InputQuestion({
        key: 'name',
        label: '文件名称',
        value: null
      }),
      new InputQuestion({
        key: 'code',
        label: '文件编码',
        value: null
      }),
      new TimeQuestion({
        key: 'borrowStartTime',
        label: '借阅时间',
        value: [],
        state: {
          format: 'YYYY-MM-DD',
          valueFormat: 'YYYY-MM-DD HH:mm:ss',
          keySplit: ['borrowStartTime', 'borrowEndTime']
        }
      }),
      new SelectQuestion({
        key: 'isOverdue',
        label: '是否逾期',
        value: null,
        type: 'dictionary',
        state: {
          filterName: 'IS_OVERDUE'
        }
      })
    ];
    return questions;
  }
  getTables() {
    const tables: TableBase<any>[] = [
      new TextTable({
        key: 'num',
        value: '序号',
        type: 'index'
      }),
      new TextTable({
        key: 'filesBoxCode',
        value: '档案编码'
      }),
      new TextTable({
        key: 'name',
        value: '文件名称'
      }),
      new TextTable({
        key: 'code',
        value: '文件编码'
      }),
      new TextTable({
        key: 'fileTypeName',
        value: '档案类型'
      }),
      new TextTable({
        key: 'secretLevel',
        value: '保密等级',
        type: 'dictionary',
        state: {
          filterName: 'SECRET_LEVEL'
        }
      }),
      new TextTable({
        key: 'creatorName',
        value: '借阅人'
      }),
      new TextTable({
        key: 'borrowTime',
        value: '借阅时间'
      }),
      new TextTable({
        key: 'renewTime',
        value: '续借时间'
      }),
      new TextTable({
        key: 'planReturnTime',
        value: '计划归还时间'
      }),
      new TextTable({
        key: 'actualReturnTime',
        value: '实际归还时间'
      }),
      new TextTable({
        key: 'isOverdue',
        value: '是否逾期',
        type: 'dictionary',
        state: {
          filterName: 'IS_OVERDUE'
        }
      })
    ];
    return tables;
  }
  getIcons() {
    const icons: TableBase<any>[] = [
      new TextTable({
        key: 'select',
        value: '导出',
        options: [
          {
            key: 'download',
            label: '导出选中',
            state: {
              url: Api.exportBorrowRecordPage,
              keyName: 'borrowInfoId',
              fileName: '档案借阅记录.xlsx'
            }
          },
          {
            key: 'download',
            label: '导出全部',
            state: {
              type: 'all',
              url: Api.exportAllBorrowRecordPage,
              fileName: '档案借阅记录.xlsx'
            }
          }
        ]
      })
    ];
    return icons;
  }
}

export default new HomeService();
